/*
Borealis Library
A library of commonly used hydrological modeling building blocks

Copyright (C) 2008  Chris Marsh

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef TESTMODULE_H
#define TESTMODULE_H

#include <borealis\AsciiRaster.hpp>
#include <boost\shared_ptr.hpp>
#include "..\AuroraTypes.hpp"

class TestModule : public AuroraTypes::ModuleBase
	{

		//expects the variables to be 
		//date  /  relative humidity 
		void run(AuroraTypes::StationList* stations, AuroraTypes::VariableList* variables, AuroraTypes::InVariables& inVars, AuroraTypes::OutVariables& outVars)
		{

			#define DEM 0
			#define RH 1
			#define FILE 0

			//simple test module where we fill a DEM with RH values
			
			float rh = stations->at(0)->Now().Get<float>(inVars[RH]);

			AuroraTypes::VariableList::const_accessor a;
			variables->find(a,inVars[DEM]);


			boost::shared_ptr<Borealis::Raster<float> > dem = boost::dynamic_pointer_cast<Borealis::Raster<float> >(boost::get<boost::shared_ptr<Borealis::VariableBase> >(a->second));
			boost::shared_ptr<Borealis::AsciiRaster> raster(new Borealis::AsciiRaster(dem->GetRow(),dem->GetCol()));

			for(unsigned int row = 0; row<dem->GetRow();row++)
			{
				for(unsigned int col = 0; col<dem->GetCol(); col++)
				{
					raster->SetRasterAt(row,col,rh);
				}
			}

			AuroraTypes::VariableList::accessor a2;
			variables->insert(a2,outVars[FILE]);
			a2->second = raster;


		}
	};

#endif